package com.example.sqlitedrugs;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.TextView;

public class ListViewBenh extends Activity {
	ExpandableListAdapter listAdapter;
	ExpandableListView expListView;
	List<String> listDataHeader;
	HashMap<String, List<String>> listDataChild;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.list_view_benh);

		// get the listview
		expListView = (ExpandableListView) findViewById(R.id.lvExp);
		expListView.setOnChildClickListener(new OnChildClickListener() {

			@Override
			public boolean onChildClick(ExpandableListView arg0, View v,
					int groupPosition, int childPosition, long id) {
				// TODO Auto-generated method stub
				switch (childPosition) {
				case 0:
					Intent newActivity = new Intent(ListViewBenh.this,
							Annotate.class);
					startActivity(newActivity);
					break;
				case 1:
					Intent newActivity1 = new Intent(ListViewBenh.this,
							Annotate.class);
					startActivity(newActivity1);
					break;
				case 2:
					Intent newActivity2 = new Intent(ListViewBenh.this,
							Annotate.class);
					startActivity(newActivity2);
					break;
				}
				
				return false;
			}
		});

		// preparing list data
		prepareListData();

		listAdapter = new ExpandableListAdapter(this, listDataHeader,
				listDataChild);

		// setting list adapter
		expListView.setAdapter(listAdapter);

	}

	private void prepareListData() {
		listDataHeader = new ArrayList<String>();
		listDataChild = new HashMap<String, List<String>>();

		// Adding child data
		listDataHeader.add("Thuốc gây tê bề mặt");
		listDataHeader.add("Vitamin-thuốc bổ");
		listDataHeader.add("Thuốc hạ sốt - giảm đau - chống");
		listDataHeader.add("Bệnh ghẻ");
		listDataHeader.add("Bệnh gút");
		listDataHeader.add("Bệnh hen phế quản");
		listDataHeader.add("Bệnh còi xương suy dinh dưỡng");
		listDataHeader.add("Cảm cúm");
		listDataHeader.add("Bệnh ho");
		listDataHeader.add("Bệnh máu mỡ cao");
		listDataHeader.add("Bệnh nhòi máu cơ tim");
		listDataHeader.add("Bệnh quai bị");
		listDataHeader.add("Táo bón");

		// Adding child data
		List<String> benh = new ArrayList<String>();
		benh.add("Emla");
		benh.add("Emla-5%");
		benh.add("Lidocain-2%");
		benh.add("Lidocaine 2% Epinephrine Normon");
		benh.add("Mastu S");
		benh.add("Medicaine-2%");
		benh.add("Otipax-1%");

		List<String> benh1 = new ArrayList<String>();
		benh1.add("AB Extra Bone-Care");
		benh1.add("Adofex");
		benh1.add("Alvextra Skin Hydrating Cream");
		benh1.add("Amigold Injection-500ml");
		benh1.add("Aminoleban-10%");
		benh1.add("Aminoplasmal Hepa-500ml");

		List<String> benh2 = new ArrayList<String>();
		benh2.add("Aceralgin");
		benh2.add("Aspegic-250mg");
		benh2.add("Aspirin pH8-500mg");
		benh2.add("Befadol-500mg");
		benh2.add("Hapacol 650mg");
		benh2.add("Paracetamol-500mg");

		List<String> benh3 = new ArrayList<String>();
		benh3.add("Eurax cream");
		benh3.add("Crotamiton");

		List<String> benh4 = new ArrayList<String>();
		benh4.add("Alaxan");
		benh4.add("Allopurinol");
		benh4.add("Loxoprofen");
		benh4.add("Solupred");
		benh4.add("Umecorn");
		benh4.add("Zyrimax");
		List<String> benh5 = new ArrayList<String>();
		benh5.add("Ambroxol 30mg");
		benh5.add("Becotide");
		benh5.add("Bricanyl");
		benh5.add("Depersolon Injection");
		benh5.add("Efedrin");
		benh5.add("Pulmicort");
		benh5.add("Symbicort");
		List<String> benh6 = new ArrayList<String>();
		benh6.add("CA C1000 Sandoz");
		benh6.add("Calcium Corbiere 10ml");
		benh6.add("Calcium Sandoz 500mg");
		List<String> benh7 = new ArrayList<String>();
		benh7.add("Acemuc");
		benh7.add("Actifed");
		benh7.add("Atussin");

		listDataChild.put(listDataHeader.get(0), benh); // Header, Child data
		listDataChild.put(listDataHeader.get(1), benh1);
		listDataChild.put(listDataHeader.get(2), benh2);
		listDataChild.put(listDataHeader.get(3), benh3);
		listDataChild.put(listDataHeader.get(4), benh4);
		listDataChild.put(listDataHeader.get(5), benh5);
		listDataChild.put(listDataHeader.get(6), benh6);
		listDataChild.put(listDataHeader.get(7), benh7);

	}
}
